package com.ruoyi.ziran.service.impl;

import java.util.Arrays;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ziran.mapper.ZrConsultMapper;
import com.ruoyi.ziran.domain.ZrConsult;
import com.ruoyi.ziran.service.IZrConsultService;
import com.ruoyi.common.core.text.Convert;

/**
 * 咨询Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-24
 */
@Service
public class ZrConsultServiceImpl extends ServiceImpl<ZrConsultMapper, ZrConsult> implements IZrConsultService
{

    /**
     * 查询咨询
     * 
     * @param id 咨询主键
     * @return 咨询
     */
    @Override
    public ZrConsult getInfoById(Long id)
    {
        return this.getById(id);
    }

    /**
     * 查询咨询列表
     * 
     * @param zrConsult 咨询
     * @return 咨询
     */
    @Override
    public List<ZrConsult> selectList(ZrConsult zrConsult)
    {
        return baseMapper.selectList(zrConsult);
    }

    /**
     * 新增咨询
     * 
     * @param vo
     * @return 结果
     */
    @Override
    public int insertZrConsult(ZrConsult vo)
    {
        vo.setStudentId(ShiroUtils.getUserId());
        vo.setCreateTime(DateUtils.getNowDate());
        this.save(vo);
        return 1;
    }

    /**
     * 修改咨询
     * 
     * @param zrConsult 咨询
     * @return 结果
     */
    @Override
    public int updateZrConsult(ZrConsult zrConsult)
    {
        zrConsult.setUpdateTime(DateUtils.getNowDate());
        zrConsult.setTeacherId(ShiroUtils.getUserId());
        zrConsult.setReplyDate(DateUtils.getNowDate());
        this.updateById(zrConsult);
        return 1;
    }

    /**
     * 批量删除咨询
     * 
     * @param ids 需要删除的咨询主键
     * @return 结果
     */
    @Override
    public int deleteZrConsultByIds(String ids)
    {
        this.removeByIds(Arrays.asList(Convert.toStrArray(ids)));
        return 1;
    }

    /**
     * 删除咨询信息
     * 
     * @param id 咨询主键
     * @return 结果
     */
    @Override
    public int deleteZrConsultById(Long id)
    {
        this.removeById(id);
        return 1;
    }
}
